<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <img src="" alt="">
  <h2></h2>

  <script>
    var img = document.querySelector('img')
    var h2 = document.querySelector('h2')

    var h = new Date().getHours()

    if( h < 12) {
      img.src = ''
      h2.innerHTML = '上午好'
    } else if( h < 18) {
      img.src = ''
      h2.innerHTML = '下午好'
    } else {
      img.src = ''
      h2.innerHTML = '晚上好'
    }

    
  </script>
</body>
</html>